﻿/*-----------------------------------------------------------------------
 * <copyright file="WorkEfficiencyQueryPage.xaml.cs" company="O-RID">
 *     Copyright (c)2010 O-RID Co.,Ltd.
 * </copyright>
 * <author>Zhang jun</author>
 * <summary>
 *              稼働率查询
 *              作成日：08/20/2010
 * </summary>
 *----------------------------------------------------------------------- 
 */
namespace Orid.Management.Statistics.OperatorUnitMangement.EfficiencyRelated.ReportWorkEfficiencyQuery
{
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Navigation;
    using Orid.Management.Statistics.OperatorUnitMangement.Common.SearchCtrl;

    /// <summary>
    /// 稼働率查询
    /// </summary>
    public partial class WorkEfficiencyQueryPage : Page
    {
        bool isExpanded = false;

        /// <summary>
        /// 构造函数
        /// </summary>
        public WorkEfficiencyQueryPage()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 当用户导航到此页面时执行。
        /// </summary>
        /// <param name="e"></param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            USEfficSelContainer efficSelContainer = new USEfficSelContainer();

            WorkEfficiencyQueryControl datagridcontrl = new WorkEfficiencyQueryControl(efficSelContainer);

            this.bWorkEfficiencyQuery.Child = efficSelContainer;

            this.bWorkEfficiencyContent.Child = datagridcontrl;

            efficSelContainer.accoridon.SelectedItemsChanged -= new System.Collections.Specialized.NotifyCollectionChangedEventHandler(accoridon_SelectedItemsChanged);
            efficSelContainer.accoridon.SelectedItemsChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(accoridon_SelectedItemsChanged);
            IsExpanded();

        }

        /// <summary>
        /// accoridon 选择ITME事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void accoridon_SelectedItemsChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            IsExpanded();
        }

        /// <summary>
        /// 判断 accoridon 收缩或展开时，DATAGRID的位置
        /// </summary>
        void IsExpanded()
        {
            if (isExpanded == true)
            {
                this.accoridonRow.Height = new GridLength(60);
                this.griddataRow.Height = new GridLength(10, System.Windows.GridUnitType.Star);
            }
            else
            {
                this.accoridonRow.Height = new GridLength(25);
                this.griddataRow.Height = new GridLength(10, System.Windows.GridUnitType.Star);
            }
            this.isExpanded = !this.isExpanded;
        }

    }
}
